package com.cq.hd.common.enums.biz;

import lombok.Getter;

/**
 * @description: 子订单状态(0 - 待支付 ， 1 - 待核销 ， 2 - 已核销 ， 3 - 已取消 ， 4 - 已过期)
 * @author: mYunYu
 * @date: 2021/8/23 14:28
 * @version: v1.0
 */
public enum SubOrderStateEnum {

    WAIT_PAY(0, "待支付"),
    WAIT_VERIFY(1, "待核销"),
    VERIFIED(2, "已核销"),
    CANCEL(3, "已取消"),
    EXPIRED(4, "已过期"),
    SETTLED(5, "已结算"),
    WAIT_AUDIT(6, "待审核")
    ;

    @Getter
    private final Integer value;

    @Getter
    private final String name;

    SubOrderStateEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static SubOrderStateEnum typeOf(Integer value) {
        SubOrderStateEnum[] values = SubOrderStateEnum.values();
        for (SubOrderStateEnum v : values) {
            if (v.value.equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static SubOrderStateEnum typeOf(String name) {
        SubOrderStateEnum[] values = SubOrderStateEnum.values();
        for (SubOrderStateEnum v : values) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        return null;
    }

}
